import React, { Component } from 'react';
import { WebView } from 'react-native';
import NavigationUtil from '../../navigator/NavigationUtil';
import BackPressComponent from '../../components/BackPressComponent';
class MyWebView extends Component {
  constructor(props){
      super(props);
      this.backPress = new BackPressComponent({backPress: () => this.onBackPress()});
      this.params = this.props.navigation.state.params;
      let {url,name} = this.params;
      this.state = {
          name,
          url,
      }
  }
  componentWillMount(){
    this.backPress.componentDidMount();
    const {navigation} = this.props;
    navigation.setParams({title:this.state.name}) //设置title;
  } 
  componentWillUnmount() {
      this.backPress.componentWillUnmount();
  }
  onBackPress() {
      NavigationUtil.goBack(this.props.navigation);
      return true;
  }
  render() {
    return (
      <WebView
        source={{uri:this.state.url}}
      />
    );
  }
}
export default MyWebView